import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

class Peo{
    private String name;
    private String peoid;
    private int workage;

    public Peo(String name, String peoid, int workage) {
        this.name = name;
        this.peoid = peoid;
        this.workage = workage;
    }

    @Override
    public String toString() {
        return "peo{" +
                "姓名'" + name + '\'' +
                ", 编号='" + peoid + '\'' +
                ", 工龄=" + workage +
                '}';
    }
}
public class HashSetTest {

    public static void t2(){
        Set set = new HashSet();
        set.add("赵云");
        set.add("马超");
        set.add("关羽");
        set.add("黄忠");
        set.add("张飞");
        //迭代
        Iterator iterator = set.iterator();
        while (iterator.hasNext()){
            Object next = iterator.next();
            System.out.print(next + "  ");
        }
    }
    public static void main(String[] args) {
        Set set = new HashSet();
        set.add(new Peo("赵云","z123",5));
        set.add(new Peo("马超","m123",6));
        set.add(new Peo("张飞","f123",10));

        Iterator iterator = set.iterator();
        while (iterator.hasNext()){
            Object next = iterator.next();
            System.out.println(next);
        }

        System.out.println("======================================");

        for (Object o : set) {
            System.out.println(o);
        }
    }
}
